package com.vision.core.cm.serv.rpc;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.vision.core.cm.exception.RpcException;

/**
 * 
 * @author Mark
 *
 */
public interface AbstractService<T> extends RemoteService {
	
	/**
	 * Saves the <tt>object</tt> into the database. The returned <tt>object</tt> instance contains the id from the database.
	 * 
	 * @param object
	 * @return
	 */
	T create(T object) throws RpcException;
	
	/**
	 * Returns the list from the database.
	 * 
	 * @return
	 */
	List<T> getAll() throws RpcException;
	
	/**
	 * Returns the object with the specified <tt>id</tt>.
	 * 
	 * @param id
	 * @return
	 */
	T getById(long id) throws RpcException;
	
	/**
	 * Updates the object. The specified <tt>object</tt> must have a valid id.
	 * 
	 * @param object
	 * @return
	 */
	T update(T object) throws RpcException;
	
	/**
	 * Deletes the object. The specified <tt>object</tt> must have a valid id.
	 * 
	 * @param object
	 * @return
	 */
	T delete(T object) throws RpcException;

}

